<template>
	<view>
		<u-notice-bar mode="horizontal" :list="list" bg-color="rgba(248, 133, 42, 0.24)" color="#F8852A"></u-notice-bar>
		<view class="back-list" v-for="(item,index) in cardList" :key="index">
			<view class="change-icon">
				<u-icon name="/static/center/change.png" size="40" v-if="item.state == 0"></u-icon>
				<u-icon name="/static/center/change-use.png" size="40" v-else></u-icon>
				<view :class="item.state == 0 ? '' : 'use'">盲盒反悔卡</view>
			</view>
			<view class="change-flex">
				<view :class="item.state == 0 ? '' : 'use'">反悔卡可让你重发一次</view>
				<view :class="item.state == 0 ? '' : 'use'">有效期至: {{item.end_time}}</view>
			</view>
			<view class="overdue" v-if="item.state == 2">
				<image src="@/static/center/overdue.png"></image>
			</view>
		</view>
		
		<u-loadmore :status="status" :load-text="loadText" @loadmore="getList" margin-bottom="40" margin-top="40" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				cardList:[],
				status: 'loadmore',
				param:{
					page: 0,
					limit: 10
				},
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
			};
		},
		onShow() {
			this.getList()
			this.configList()
		},
		onReachBottom() {
			this.status = 'loading'
			this.getList()
		},
		methods:{
			configList(){
				this.$net.req('/config/getBatchByKeys',{keys:['go_back_notice']}).then(res=>{
					if(res.code == 200){
						this.list = res.data.go_back_notice.split(',')
					}
				})
			},
			getList(){
				this.param.page = this.param.page + 1
				this.$net.req('/RegretCard/getlists',this.param).then(res=>{
					if(res.code == 200){
						if (res.data.list.length < 10) {
							this.status = 'nomore'
						} else {
							this.status = 'loadmore'
						}
						this.cardList = this.cardList.concat(res.data.list)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.back-list{
		background-image: url(@/static/center/back-list.png);
		width: 702rpx;
		height: 156rpx;
		position: relative;
		background-size: contain;
		margin: 20rpx auto 0;
		padding: 32rpx;
		
		&:first-child{
			margin-top: 32rpx;
		}
		
		.change-icon{
			font-size: 32rpx;
			color: #333333;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			view{
				margin-left: 10rpx;
			}
		}
		.change-flex{
			display: flex;
			justify-content: space-between;
			font-size: 24rpx;
			font-family: HarmonyOS_Sans_SC;
			color: #F8852A;
			
			view:nth-child(2){
				color: #B4B3BA;
			}
		}
		.use{
			color: #DEDEDE !important;
		}
		.overdue{
			position: absolute;
			width: 100rpx;
			height: 100rpx;
			right: 0;
			top: 0;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
